package com.xzy.web.controller;

import com.xzy.custom.Page;
import com.xzy.custom.ResultMap;
import com.xzy.entities.BookType;
import com.xzy.entities.Record;
import com.xzy.service.RecordService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * TODO
 *
 * @author XiangZhongyi
 * ClassName: RecordController
 * date: 2022/3/27 14:18
 */
@Controller
public class RecordController {

    @Autowired
    private RecordService recordService;

    @RequestMapping("/record")
    public String bookType(){
        return "admin/record";
    }

    @RequestMapping("/findAllRecord")
    @ResponseBody
    public ResultMap<List<Record>> findAllBookType(Page page, @RequestParam("limit")int limit,@Param("name") String name){
        page.setRows(limit);
        page.setPage((page.getPage()-1)*limit);
        Integer total = recordService.findRecordCount(page,name);
        List<Record> list = recordService.findAllRecord(page,name);
        return new ResultMap<List<Record>>("",list,0,total);
    }
}
